
//
//  HotModelFrame.m
//  庐山通
//
//  Created by zcj on 15-11-4.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "HotModelFrame.h"
#import "HotModel.h"
// 间隙
#define margen 10
// 单元格的宽
#define CellW (ScreenWidth - margen*3)*0.5
@implementation HotModelFrame
- (void)setHotModel:(HotModel *)hotModel
{
    _hotModel = hotModel;

    // 图片
//    标题  时间
//    
//    img
//    
//    位置  评论
//    
//    
//    头像  用户名
    // 标题
    CGFloat titleX = margen * 0.5;
    CGFloat titleY = titleX;
    CGFloat titleW = CellW * 0.5;
    CGSize titelWH = [hotModel.title boundingRectWithSize:CGSizeMake(titleW, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12]} context:nil].size;
    _titleF = CGRectMake(titleX, titleY, titleW, titelWH.height);
    // 时间
    CGFloat posttimeX = CGRectGetMaxX(_titleF) + margen * 0.5;
    CGFloat posttimeY = titleY;
    CGFloat posttimeW = titleW;
    CGSize posttimeWH = titelWH;
    _positionF = CGRectMake(posttimeX, posttimeY, posttimeW, posttimeWH.height);
    
    // 图片
    CGFloat imgX = titleX;
    CGFloat imgY = CGRectGetMaxY(_positionF) + margen;
    CGFloat imgW = CellW -5;
    CGFloat imgH = imgW;
    _imgF = CGRectMake(imgX, imgY, imgW, imgH);
    
    // 位置
   
    CGFloat postionX = imgX;
    CGFloat postionY = CGRectGetMaxY(_imgF) + margen;
    CGFloat postionW = posttimeW;
    CGSize postionH = posttimeWH;
    _positionF = CGRectMake(postionX, postionY, postionW, postionH.height);
    
    // 品论
    CGFloat titX = posttimeX;
    CGFloat titY = postionY;
    CGFloat titW = postionW -8;
    CGSize titH = posttimeWH;
    _tidF = CGRectMake(titX, titY, titW, titH.height);
    
    // 图片
    CGFloat avatarX = postionX;
    CGFloat avatarY = CGRectGetMaxY(_tidF)+ margen;
    CGFloat avatarW = 25;
    CGFloat avatarH = 25;
    _avatarF = CGRectMake(avatarX, avatarY, avatarW, avatarH);
    
    
    // 名称
    CGFloat usernameX = CGRectGetMaxX(_avatarF) + 4 * margen;
    CGFloat usernameY = avatarY + 5;
    CGFloat usernaemW = CellW - CGRectGetMaxX(_avatarF) + 3 * margen;
    CGSize usernameWH = [hotModel.username boundingRectWithSize:CGSizeMake(usernaemW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:10]} context:nil].size;
    _usernameF = CGRectMake(usernameX, usernameY, usernaemW, usernameWH.height);
    
    _cellH = CGRectGetMaxY(_usernameF) +5*margen;
 
}
@end
